home
***
CD-ROM
|
disk
|
FTP
|
other
***
search
/
Ham Radio 2000
/
Ham Radio 2000.iso
/
ham2000
/
packet
/
p_tapr
/
tnchst
/
host.c
< prev
next >
Wrap
Text File
|
1989-07-30
|
2KB
|
117 lines
/*******
Host link controller. Manages "host" links on the RS-232 port
vis-a-vis c2 links of LOh.
*********/
/* host literals */
#include "host.lit"
/* data structures, c2 structures */
#include "\cpm\loh\c2istr.inc"
/* host specific structures */
#include "hoststrc.inc"
/* data structure */
#include "datastrc.inc"
/********* variables common to all host links *************/
struct host_struct hosts[1] ; /* set up for 1 hcb now */
/** reset the data counters, NULL the data link list pointers, for a
specific host **/
hdreset( hcb )
struct host_struct *hcb;
{
hcb->htxseq = hcb->hrxseq = hcb->hremseq = 0 ;
/* reset seq #s */
hcb->htx = hcb->hrx = (struct data_struct *) NULL ;
/* init link list pointers */
}
free_list( ptr )
struct data_struct **ptr;
{
struct data_struct *tmp;
tmp = *ptr ; /* traverse the list */
while ( *ptr ) /* while there are rmng nodes */
{
tmp = (*ptr)->data_link ; /* get ptr to next */
#if MSDOS
free( *ptr );
#else
sw_free( DATABUFFER , *ptr );
#endif
/* free the buffer */
*ptr = tmp ;
/* reload the list entry pointer */
} /* endwhile */
}
/** clears the link list, frees remaining structures to DATABUFFER pool **/
hdclear( hcb )
struct host_struct *hcb;
{
free_list( &hcb->htx ); /* free everything in the */
free_list( &hcb->hrx ); /* tx and rx data lists */
}
/** free the elements in the linked list pointed to by the byte ptr
at the adress ptd to by the parameter **/
host_init()
{
hosts[0].hstate = HSIDLE ; /* idle the host link */
}
/** timer handler for hosts. should be slept from an executive or
called periodically from something else, for each
host structure
**/
hosttask( hcb )
struct host_struct *hcb;
{
if ( hcb->hstate != HSIDLE ) /* if not idling */
{
if ( hcb->htime ) /* if timer running */
{
if ( ! --hcb->htime ) /* if timer now expired */
host_event( hcb , HTIMER_EVENT , NULL );
/* then show expired event*/
}
}
#if MSDOS
#else
sleep( hosttask , hcb , BAK0 , HRETRYTIME );
#endif
}
main(){ }